<template>
	<eui-page-frame topHeight="260" bottomHeight="88">
		<template #top>
			<view class="content-img">
				<eui-navbar ref="EuiNavBar" :title="title" color="#000000" backgroundColor="#FFFFFF"
					:storeName="sUserStoreName" :storeId="sUserStore" :displayable="true">
				</eui-navbar>
				<view class="top-view">
					<eui-search-bar ref="RdsSearchBar" leftIcon="icon-sousuo" v-model="searchText"
						placeholder="请选择生鲜采购单" readonly @confirm="searchConfirm" @leftIconClick="scanCode" radius="30">
					</eui-search-bar>
					<view style="width: 10%;">
						<eui-uicons size='36' @click="selectOpen('c_id')" fontFamily="enjoyIcon5"
							customPrefix="icon-shaixuansousuo" />
					</view>

				</view>
			</view>
		</template>
		<eui-page-content>
			<view class="footer-view">
				<eui-card title="车辆信息" showTitleLine="true" h-padding="28">
					<template v-slot:extra>
						<view class="extra-view" @click="changeBasicStatus">
							<eui-uicons :type="showBasic ? 'up' : 'down'" size="24" />
						</view>
					</template>
					<view v-if="showBasic">
						<eui-card-input v-model="mainData.c_num_plate" title="车牌号" type="text" placeholder="请输入车牌号"
							maxlength="10" />
						<eui-card-input v-model="mainData.c_driver" title="司机姓名" type="text" placeholder="请输入司机姓名"
							maxlength="10" />
						<eui-card-input v-model="mainData.c_model" title="车型号" type="text" placeholder="请输入车型号"
							maxlength="20" />
						<eui-card-input v-model="mainData.c_driver_tel" title="司机电话" type="text" placeholder="请输入司机电话"
							maxlength="11" isBlur fieldName="c_driver_tel" @confirm="validateTopDetail"
							:itemIndex="1" />
						<eui-card-input v-model="mainData.c_attendant" title="随车员" type="text" placeholder="请输入随车员"
							maxlength="10" />
					</view>
				</eui-card>
				<view style="margin-top: 20rpx;">
					<eui-card title="费用信息" showTitleLine="true" h-padding="28">
						<template v-slot:extra>
							<view class="extra-view" @click="changeBasic2Status">
								<eui-uicons :type="showBasic2 ? 'up' : 'down'" size="24" />
							</view>
						</template>
						<view v-if="showBasic2">
							<eui-card-input v-model="feeData.c_amount" title="费用金额" type="text" displayable="false"
								placeholder="" />
							<eui-card-input v-model="feeData.c_id" title="费用单" type="text" placeholder="请选择费用单"
								displayable="false" rightIconType="right" @iconClick="selectOpen('fee')" />
							<eui-card-input v-model="feeData.c_inv_fee_rate" title="发票代开费率" type="radio"
								:range="payTaxRateDatas" />

							<view v-for="(item, index) in feeList">
								<eui-card-input v-model="item.c_fee_amount" :title="item.c_fee_name" isBlur
									fieldName="c_fee_item" @confirm="validateFee" :itemIndex="index" type="number"
									maxlength="9" :displayable="feeData.c_id" />
							</view>
						</view>
					</eui-card>
				</view>
				<view style="margin-top: 20rpx;">
					<eui-base-card v-for="(item, index) in loadList" :checkable="true" @check="leftChecked(item)"
						:checked="item.checked" :checkItemdisable="item.c_wait_n <= 0"
						:title="'['+item.c_gcode+']'+item.c_gname">
						<template #left>
						</template>
						<eui-detail-show :items="cgDataItems" v-model="loadList[index]"></eui-detail-show>
						<eui-card-input v-model="item.c_n_loading" title="本次装车量" type="number"
							:placeholder="item.c_wait_n>0?'请输入本次装车量':''" maxlength="10" fieldName="c_n_loading"
							:itemIndex="index" :required="item.c_wait_n>0" :displayable="item.c_wait_n<=0"
							@confirm="validateDetail" />
					</eui-base-card>
				</view>
			</view>
		</eui-page-content>
		<template #bottom>
			<view class="bt-button">
				<eui-button type="max2" :disabled="!(mainData.c_status == '0' && detailData.length > 0)" title="一键装车"
					@buttonClick="selectAll" />
				<eui-button type="max" :disabled="!(mainData.c_status == '0' && detailData.length > 0)" title="确认装车"
					@buttonClick="submit" />
			</view>

		</template>
	</eui-page-frame>
</template>

<script setup type="ts">
	import { ref, reactive, onMounted } from 'vue';
	import {useMainStore} from "@/store/modules/store";
	import {useLoginStore} from "@/store/modules/useLoginStore";
	import { validateStores } from '@/hooks/useValidateMethod';
	import dateRangUtil from '../../../common/dateRangUtil';
	import { getRelatedName, getDictName,getDictSelectList,getUserDictList, getDictSelect,getFreshLocationName } from '../components/RelatedName.js';
	import Enjoy from "@/common/enjoy";
	import { initTaxRate, payTaxRateItems } from '@/hooks/useTaxRateHook';
	import {onLoad} from "@dcloudio/uni-app";
	import { init } from '@/hooks/init';
	import { calcAtInByPt} from '@/hooks/useCalculateMethod';
	import useService from '@/hooks/useService';
	import dayjs from 'dayjs';
	const service = useService({ prefix: "scApi" });
	const bcService = useService({ prefix: "bcApi" });
	const mainService = useService({prefix:'mainApi'});
	const mainStore = useMainStore();
	const LoginStore = useLoginStore();
	const EuiNavBar = ref(null);
	const RdsSearchBar = ref(null);
	const { loginInfo } = mainStore;
	const sUserStore = ref('');
	const sUserStoreName = ref('');
	const sUser = ref('');
	const title = ref('装车运输单');
	const mainData = ref({
                c_status: '0',
				c_num_plate:'',
				c_model:'',
				c_driver:'',
				c_driver_tel:'',
				c_attendant:'',
            });
	const isCurrentGds = ref([]);
	const c_id = ref(''); //单据号
	const searchText = ref('');
	const c_status = ref('0');
	const selectType = ref('');
	const uniFabContent=ref([
	                {
	                    text: '删除单据'
	                },
	            ]);
	const feeList = ref([]);
	const newList = ref([]);
	const modifiedList = ref([]);
	const delList = ref([]);
	const options = ref([
	                {
	                    text: '删除',
	                    style: {
	                        backgroundColor: '#F56C6C',
	                    }
	                },
	            ]);
	const payTaxRateDatas = ref([]);
	const feeData = ref({});
	const loadList = ref([]);
	const detailData = ref([]);
	const currentGds = ref({});
	const currentGdsIndex = ref(0);
	const currentPage = ref(1);
	const showBasic = ref(true);
	const showBasic2 = ref(true);
	const cgDataItems = ref([
		{
		        label: "采购金额",
		        prop: "c_at_pay",
		        type: "text",
				colSpan: 12,
		        element: {
		             precision: 2,
		        },
		    },
		    {
		        label: "采购数量",
		        prop: "c_n_total_pur",
		        type: "text",
				colSpan: 12,
		        element: {
					 precision: 2,
		        },
		    },
		    {
		        label: "已装车量",
		        prop: "c_n_loaded",
		        type: "text",
				colSpan: 12,
		        element: {
		            precision: 2,
		        },
		    },
		    {
		        label: "待装车量",
		        prop: "c_wait_n",
		        type: "text",
				colSpan: 12,
		        element: {
		            precision: 2,
		        },
		    },
		    {
		        label: "本次装车金额",
		        prop: "c_load_amount",
		        type: "text",
				colSpan: 12,
		        element: {
		            precision: 2
		        },
		    },
		    {
		        label: "剩余金额",
		        prop: "c_surplus_amount",
		        type: "text",
				colSpan: 12,
		        element: {
		            precision: 2,
		        },
		    }
	])
	
	const changeBasicStatus = () => {
	  showBasic.value = !showBasic.value;
	}
	const changeBasic2Status = () => {
	  showBasic2.value = !showBasic2.value;
	}
	const setDefault = (userStore) => {
		sUserStore.value = userStore||loginInfo.sUserStore;
		sUserStoreName.value = userStore?getRelatedName('rdsStores', userStore):loginInfo.sUserStoreName;
		sUser.value = loginInfo.sUser;
	}
	const selectOpen = (type) => {
		if(type==='c_id'){
			uni.navigateTo({
			    url: "../modals/freshPurchase/index?storeId=" + sUserStore.value
			});
		}
		else{
			uni.navigateTo({
			    url: "../modals/feeItem/index"
			});
		}
	    
	}
	
	onLoad(async (option) => {
		mainData.value.c_id = option.c_id;
		await initTaxRate();
		payTaxRateDatas.value = payTaxRateItems;
		if (option.c_id) {
			  await loadBillQuery(option.c_id);
		}
		//生鲜采购跳转到index页面
    if (option.c_src_id) {
      searchText.value = option.c_src_id;
      await billQuery(option.c_src_id);
    }
		setDefault(option.storeId);
	})
	/**
	 * 查询装车运输单
	 * @param {单号} billId 
	 */
	const loadBillQuery = async(billId) => {
		if (!billId) {
			return;
		}
		const req = {
			BillId: mainData.value.c_id,
		};
		uni.showLoading({ title: "正在加载...", mask: true })
		const result = await service.request('装车运输单', 'EnjoyBillQuery', req,'');
		uni.hideLoading();
		if (result.ds.length > 0) {
			mainData.value = result.ds[0];
			console.log('mainData',mainData.value)
			detailData.value = result.ds1;
			detailData.value.forEach(x => {
				const c_n_loaded = x.c_n_loading;
				x.c_n_loaded = c_n_loaded;
				x.c_n_loading = x.c_n_total_pur - c_n_loaded;
				x.c_load_amount = x.c_n_loading * x.c_pt_pay;
				x.c_surplus_amount = x.c_at_pay - (c_n_loaded * x.c_pt_pay);
				x.c_wait_n = x.c_n_total_pur - c_n_loaded;
			});

			// this.$refs.paging.setLocalPaging(this.detailData);
			await feeBillQuery(mainData.value.c_pur_fee_id);
		}
	}
	
	const feeBillQuery = async(billId) => {
		if (!billId) {
			return;
		}
		const req = {
			BillId: billId,
		};
		const result = await bcService.request('采购费用方案维护', 'EnjoyBillQuery', req,'');
		if (result.ds.length > 0) {
			feeData.value = result.ds[0];
			feeData.value.c_id = feeData.value.c_no;
			feeData.value.c_pl_no = mainData.value.c_pl_no??'';
			feeData.value.c_approve_status = '0';
			feeData.value.c_status = '0';
			feeData.value.c_mk_store_id = mainData.value.c_mk_store_id;
			feeData.value.c_mk_dt = mainData.value.c_mk_dt;
			feeData.value.c_mk_userno = mainData.value.c_mk_userno;
			feeData.value.c_src_id = searchText.value;
			feeData.value.c_src_type = '5C1';
			feeList.value = result.ds1;
			const list = getUserDictList('生鲜采购费用')
			console.log('生鲜采购费用',list)
			feeList.value.map(x => {
				const data = list.find(y => y.c_id == x.c_fee_item);
				if (data) {
					x.c_fee_name = data.c_name;
					x.c_fee_amount= x.c_fee_amount?.toString();
				}
			})
			feeData.value.c_amount = feeList.value.reduce((pre, current) => pre + current.c_fee_amount * 1, 0);
		}
	}
	
	 //查询生鲜采购单
	const billQuery = async(billId) => {
		if (!billId || billId == 1) {
			return;
		}
		const req = {
			BillId: billId,
		};
		const result = await service.request('生鲜采购单', 'EnjoyBillQuery', req,'');
		if (result.ds.length > 0) {
			const item = result.ds[0];
			detailData.value = result.ds1;
			feeData.value = item ? {
				c_id: null,
				c_pl_no: item.c_pl_no || '',
				c_amount: 0,
				c_inv_fee_rate: 0, 
				c_desc: '',
				c_charge_userno: '',
				c_status: '0',
				c_mk_store_id: item.c_mk_store_id,
				c_mk_dt: item.c_mk_dt,
				c_mk_userno: item.c_mk_userno,
				c_approve_status: '0',
			} : {};
			initFeeDict();
			//赋值装车单主表
			mainData.value = item ? {
				c_id: '',
				c_dc_store_id: item.c_dc_store_id,
				c_d_store_id: item.c_d_store_id,
				c_wave: item.c_wave,
				c_pur_fee_id: '',
				c_amount: 0,
				c_pl_no: item.c_pl_no||'',
				c_buyer_no: item.c_buyer_no,
				c_num_plate: item.c_num_plate,
				c_model: item.c_model,
				c_driver: item.c_driver,
				c_driver_tel: item.c_driver_tel,
				c_attendant: item.c_attendant,
				c_src_id: item.c_id,
				c_mk_store_id: item.c_mk_store_id,
				c_mk_dt: item.c_mk_dt,
				c_mk_userno: item.c_mk_userno,
				c_status: '0',
				c_approve_status: '0',
			} : {};
			//赋值装车单明细
			loadList.value = detailData.value.map((x, i) => {
				const data = {
					c_tenant_id: x.c_tenant_id,
					c_sort: i,
					c_gsort: x.c_sort,
					c_gcode: x.c_gcode,
					c_gname: x.c_gname,
					c_provider: x.c_provider,
					c_avg_weight: x.c_avg_weight??0,
					c_n_total_req: x.c_n_total_req??0,
					c_n_total_pur: x.c_n_total_pur??0,
					c_n_loaded: x.c_n_loaded,//已装车量
					c_pur_fee: 0,
					c_pt_pay: x.c_pt_pay,
					c_at_pay: x.c_at_pay,
					c_d_type: x.c_d_type,
					c_s_mode: x.c_s_mode,
					// c_note: x.c_note
					c_wait_n: x.c_n_total_pur - x.c_n_loaded,//待装车量
					c_n_loading: x.c_n_total_pur - x.c_n_loaded,//本次装车量
					c_load_amount: (x.c_n_total_pur - x.c_n_loaded) * x.c_pt_pay,//本次装车金额
					c_surplus_amount: x.c_at_pay - (x.c_n_loaded * x.c_pt_pay), //剩余金额
					checked: false,
				}
				return data;
			});
			console.log('loadListloadList',loadList.value)
		} 
	}
    
	const initFeeDict = async() => {
		const list = await getUserDictList('生鲜采购费用')
		feeList.value = list.map(x => {
			const data = {
				c_fee_item: x.c_id,
				c_fee_amount: parseFloat(0).toFixed(2),
				c_fee_name: x.c_name,
			}
			return data;
		});
		calcMainAmount();
		return list;
	}
   
    const leftChecked = (item) => {
       if (item) {
		   if(item.c_wait_n<=0){
			   return;
		   }
           item.checked = !item.checked;
       }
    }
	const validateTopDetail = (args)=>{
		 const { type, fieldName, oldValue, newValue, itemIndex } = args;
		 const regx = /(^(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(^[1][35789]\d{9}))$/
		 if(newValue){
			 if (!regx.test(newValue)) {
				uni.showToast({
					duration: 2000,
					icon: 'none',
					title: '请输入正确的电话号码'
				});
				mainData.value.c_driver_tel="";
				return;
			 }
		 }
	}
    const validateFee = (args) => {
	   const { type, fieldName, oldValue, newValue, itemIndex } = args;
	   const item = feeList.value[itemIndex];
	   item.c_fee_amount = parseFloat(newValue).toFixed(2);
	   calcMainAmount();
    }
    const validateDetail = (args) => {
		const { type, fieldName, oldValue, newValue, itemIndex } = args;
		const item = loadList.value[itemIndex];
		if (newValue < 0) {
			uni.showToast({
				duration: 2000,
				icon: 'none',
				title: `本次装车量不能小于0！`
			});
			item.c_n_loading = 0;
			return;
		}
		if (newValue > item.c_wait_n) {
			uni.showToast({
				duration: 2000,
				icon: 'none',
				title: `本次装车量不能大于待装车量[${item.c_wait_n}]！`
			});
			item.c_n_loading = item.c_wait_n;
			return;
		}
		calcRowAmount(item);
	}
    /**
   * 计算当前金额
   */
   const calcRowAmount = (item) =>{
	   item.c_load_amount = calcAtInByPt({ c_pt: item.c_pt_pay, c_n: item.c_n_loading });
	}
   const calcMainAmount = () => {
	   feeData.value.c_amount = feeList.value.reduce((pre, current) => Number(pre) + Number(current.c_fee_amount), 0);
   }
   const selectAll = async() =>{
	  loadList.value.forEach(x => 
		{
		   if (x.c_wait_n > 0) {
			   x.checked = true;
			   x.c_n_loading = x.c_wait_n;   //一键装车是直接使用待装车数量还是输入的数量？？？
			   calcRowAmount(x)
		   }
	   });
	   await submit();
   }
   const submit = async() =>{
	   console.log('mainData.value',mainData.value)
	   if(!mainData.value.c_num_plate){
		   uni.showToast({
		   			   duration: 2000,
		   			   icon: 'none',
		   			   title: '请输入车牌号！'
		   });
		   return;
	   }
	   if(!mainData.value.c_driver){
		   uni.showToast({
					   duration: 2000,
					   icon: 'none',
					   title: '请输入司机姓名！'
		   });
		   return;
	   }
	   if(!mainData.value.c_model){
		   uni.showToast({
					   duration: 2000,
					   icon: 'none',
					   title: '请输入车型号！'
		   });
		   return;
	   }
	   if(!mainData.value.c_driver_tel){
		   uni.showToast({
					   duration: 2000,
					   icon: 'none',
					   title: '请输入司机电话！'
		   });
		   return;
	   }
	   const itemIndex = loadList.value.findIndex(x => x.checked == true);
	   if (itemIndex == -1) {
		   uni.showToast({
			   duration: 2000,
			   icon: 'none',
			   title: '请先选择装车商品！'
		   });
		   return;
	   }
	   for (let i = 0; i < loadList.value.length; i++){
		   let item = loadList.value[i];
		   if (item.c_n_loading < 0) {
				uni.showToast({
					duration: 2000,
					icon: 'none',
					title: `本次装车量不能小于0！`
				});
				item.c_n_loading=0;
				return;
		   }
		   if (item.c_n_loading > item.c_wait_n) {
				uni.showToast({
					duration: 2000,
					icon: 'none',
					title: `本次装车量不能大于待装车量[${item.c_wait_n}]！`
				});
				item.c_n_loading = item.c_wait_n;
				return;
		   }
	   }
	   let content = '';
	   const c_amount = feeList.value.reduce((pre, current) => pre + current.c_fee_amount * 1, 0);
	   if (!feeData.value.c_id && c_amount <= 0) {
		   content = '费用信息为空，'
	   }
	   uni.showModal({
		   title: ' 提示',
		   content: content + '确认装车并审核单据?',
		   showCancel: true,
		   success: async (res) => {
			   if (res.confirm) {
				   uni.showLoading({ title: "正在装车...", mask: true })
				   //第一步：保存采购费用单
				   const feeBillId = await saveFeeBill();
				   //第二步：审核采购费用单
				   await auditFeeBill();
				   //第三步：保存装车运输单
				   mainData.value.c_pur_fee_id = feeBillId;
				   mainData.value.c_amount = feeData.c_amount;
				   await saveBill();
				   //第四步：审核装车运输单
				   await auditLoadBill();
				   //第五步：刷新页面
				   await billQuery(searchText.value);
				   uni.hideLoading();
				   uni.showToast({
					   duration: 2000,
					   icon: 'none',
					   title: '操作成功！'
				   });
			   }
		   }
	   });
   }
   
    /**
	* 保存采购费用单
	*/
   const saveFeeBill = async () => {
	   const getBilllIdReq = {
		   BillIdKeyValue: {
			   key: "c_id",
			   value: ""
		   },
		   BillVariable: "",
		   TableName: "tb_po_fsh_load",
		   BillName: "采购费用单"
	   }
	   console.log('采购费用单单号生成服务')
	   const billlId = await mainService.request('单号生成服务', 'EnjoyGetBillId', getBilllIdReq,'5D1');
	   if (billlId) {
		   feeData.value.c_id = billlId;
		   feeData.value.c_mk_userno = sUser.valie;
		   feeData.value.c_mk_dt = dayjs().format('YYYY-MM-DD HH:mm:ss');
		   feeList.value.forEach(x => x.c_id = feeData.value.c_id)
	   } else {
		   uni.showToast({
			   duration: 2000,
			   icon: 'none',
			   title: '单号生成失败！'
		   });
		   return;
	   }

	   const req = {
		   NewList: [feeData.value],
		   ModifiedList: [],
		   DelList: [],
		   TableName: "tb_po_fsh_pur_fee",
		   PrimaryKeys: ["c_tenant_id", "c_id"],
		   ChildData: [{
			   ChildTableName: "tb_po_fsh_pur_fee_detail",
			   ParentTableName: "tb_po_fsh_pur_fee",
			   ChildColumnNames: ["c_id"],
			   ParentColumnNames: ["c_id"],
			   ChildSaveModel: {
				   NewList: feeList.value,
				   ModifiedList: [],
				   DelList: [],
				   TableName: "tb_po_fsh_pur_fee_detail",
				   PrimaryKeys: ["c_tenant_id", "c_id", "c_fee_item"]
			   },
		   }],
		   BillSet: {
			   BillIdKeyValue: {
				   key: "c_id",
				   value: billlId
			   },
			   BillVariable: "",
			   TableName: "tb_po_fsh_pur_fee",
			   BillName: "采购费用单"
		   },
	   };
	   console.log('采购费用单保存')
	   const result = await service.request('采购费用单', 'EnjoyBillSaveNew', req,'5D1');
	   return result.billlId;
   } 
	
	// 保存装车运输单数据
	const saveBill = async() => {
		const flag = mainData.value.c_id;
		if (!mainData.value.c_id) {
			const getBilllIdReq = {
				BillIdKeyValue: {
					key: "c_id",
					value: ""
				},
				BillVariable: "",
				TableName: "tb_po_fsh_load",
				BillName: "装车运输单"
			}
			console.log('装车运输单单号生成服务')
			const billlId = await mainService.request('单号生成服务', 'EnjoyGetBillId', getBilllIdReq,'5H1');
			if (billlId) {
				mainData.value.c_id = billlId;
			}
		} else {
			mainData.value.c_modify_userno = sUser.value;
			mainData.value.c_modify_dt = dayjs().format('YYYY-MM-DD HH:mm:ss');
		}

		loadList.value.forEach(x => x.c_id = mainData.value.c_id)
		newList.value = loadList.value.filter(x => x.rowType == 1 || !x.hasOwnProperty('rowType') && x.checked == true);
		modifiedList.value = loadList.value.filter(x => x.rowType == 2 && x.checked == true);
		const req = {
			NewList: flag ? [] : [mainData.value],
			ModifiedList: flag ? [mainData.value] : [],
			DelList: [],
			TableName: "tb_po_fsh_load",
			PrimaryKeys: ["c_tenant_id", "c_id"],
			ChildData: [{
				ChildTableName: "tb_po_fsh_load_g",
				ParentTableName: "tb_po_fsh_load",
				ChildColumnNames: ["c_id"],
				ParentColumnNames: ["c_id"],
				ChildSaveModel: {
					NewList: newList.value,
					ModifiedList: modifiedList.value,
					DelList: delList.value,
					TableName: "tb_po_fsh_load_g",
					PrimaryKeys: ["c_tenant_id", "c_id", "c_sort"]
				},
			}],
			BillSet: {
				BillIdKeyValue: {
					key: "c_id",
					value: mainData.value.c_id
				},
				BillVariable: "",
				TableName: "tb_po_fsh_load",
				BillName: "装车运输单"
			},
		};
		console.log('装车运输单保存服务')
		const result = await service.request('装车运输单', 'EnjoyBillSaveNew', req,'5H1');
		newList.value = [];
		modifiedList.value = [];
		delList.value = [];
		return result.BillId;
	}
	//采购费用单 审核
   const auditFeeBill = async() => {
		const req = {
			BillId: feeData.value.c_id,
			UserNo: sUser.value,
		}
		console.log('采购费用单审核服务')
		const result = await service.request('采购费用单', 'EnjoyBillAudit', req,'5D1');
	}
	//装车运输单审核
	const auditLoadBill = async() => {
		const req = {
			BillId: mainData.value.c_id,
			UserNo: sUser.value,
		}
		console.log('装车运输单审核服务')
		const result = await service.request('装车运输单', 'EnjoyBillAudit', req,'5H1');
	}
   const SelectionChanged = async(item) => {
		switch (item.type) {
			case 'c_fee_id':
				feeData.value.c_id = item.c_fee_id;
				feeData.value.c_amount = item.c_amount;
				mainData.value.c_pur_fee_id = item.c_fee_id;
				await feeBillQuery(item.c_fee_id);
				break;
			case 'c_id':
				searchText.value = item.c_id;             
				await billQuery(item.c_id);
				break;
		}
	}
	defineExpose({
		SelectionChanged
	})
</script>

<style lang="scss" scoped>
	@import '../../../main.scss';
	@import '../../../static/font/enjoyicon5.0/iconfont.css';

	.content {
		display: flex;
		flex: 1;
		flex-direction: column;
		background-color: #F2F2F2;
		padding: 0px !important
	}

	.content-img {
		background-color: #FFFFFF;
		background-size: 100% 176rpx;
		background-repeat: no-repeat;
		width: 100%;
	}

	.navigation {
		flex: 0 0 auto;
		margin-bottom: 5px;
	}

	.main-view {
		flex: 1;
		flex-direction: column;
	}

	.search-fields {
		width: 100%;
		background: #FFFFFF;
		position: relative;

		.bottom {
			background: #ffffff;
			border-top: 1rpx solid $uni-line-color;
			display: flex;
			justify-content: center;
			padding: 20rpx;
		}
	}

	.top-view {
		width: 100%;
		height: 88rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		background: #ffffff;
	}

	.extra-view {
		margin-right: 30rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		width: 60rpx;
		height: 100%;
	}

	.footer-view {
		width: 100%;
		flex: 1;
	}

	.list-scroll {
		width: 100%;
		height: 300rpx;
		box-sizing: border-box;
	}

	.bottom-view {
		width: 100%;
		height: 100rpx;
		background: #FFFFFF;
		display: flex;
		justify-content: flex-end;
		align-items: center;
		flex-direction: row;
	}

	.center-style {
		display: flex;
		justify-content: center;
		align-items: center;
		height: 100%;
		margin-right: 20rpx;
		gap: 20rpx;
	}

	//内容行
	.item-view {
		display: flex;
		flex-wrap: wrap;
		flex-direction: row;
		align-items: center;
		margin-top: 16rpx;
		row-gap: 8rpx;
	}

	.line-view {
		width: 100%;
		height: 1rpx;
		background: #EEEEEE;
		margin: 20rpx 0;
	}

	.fab-view {
		width: 60rpx;
		height: 100%;
		//background: #00aaff;
		display: flex;
		align-items: center;
		justify-content: center;
		position: relative;
	}

	.m-list-top {
		display: grid;
		grid-template-columns: 50% 50%;
		padding: 0 0 16rpx;
		border-bottom: 2px solid #c8c7cc;
		font-size: 24rpx;
	}

	// ::v-deep .e-card {
	// 	margin-left: 0rpx !important;
	// 	margin-right: 0rpx !important;
	// }

	// ::v-deep .e-card__content {
	// 	margin-left: 0rpx !important;
	// 	margin-right: 0rpx !important;
	// }

	::v-deep .list_cell {
		width: 100% !important;
		margin: 0 !important;
	}

	.bottom {
		height: 70rpx;
		display: flow-root;
		text-align: center;
		border-bottom-left-radius: $uni-border-radius-lg;
		border-bottom-right-radius: $uni-border-radius-lg;
		padding: $uni-spacing-col-sm*2 $uni-spacing-row-sm;
		background: $uni-bg-color;
		text-align: right;
	}

	.bt-button {
		background-color: #FFFFFF;
		padding: 10rpx 0rpx;
		display: flex;
		justify-content: space-around;
		align-items: center;
	}

	::v-deep .m-card-input-title {
		text-align: left;
	}

	::v-deep .m-card-radio-view {
		padding: 24rpx 0rpx 16rpx !important;
	}

	::v-deep .m-card-input-view {
		padding: 24rpx 0rpx 16rpx !important;
	}
</style>